OK, I'm stuck on getting it to store it properly.
How can I do this without strdup? If I just directly put it in the pointer, it doesn't work.
if it were a single character, you'd do something like
void Encrypt(char source, char & output);
But how do you do that with an array?
Code:
char * Encrypt ( const char * input, const char * key, char * output )
{
std::string result = "\0";
int inputlength = strlen(input);
int keylength = strlen(key);
for (int i=0; i<inputlength; i++)
result += input[i] ^ key[i % keylength];
output = strdup(result.c_str());
return output;
}
int main()
{
char * lala = "Hi. This is a test.";
const char * key = "STEAM_0:0:4549308";
char * result = NULL;
result = Encrypt( lala, key, result );
printf("%s \n%s\n%s", lala, key, result);
//for (int i=0; i<strlen(result); i++)
// printf("%i", result[i]);
//printf("\n");
free(result);
return 0;
}